<template>
  <div class="news-list">
    <!-- <van-card
      v-for="item in newslist"
      :key="item.id"
      :num="item.click"
      :price="item.add_time"
      :title="item.title"
      :thumb="item.img_url"
    /> -->

    <van-card
      v-for="item in newslist"
      :key="item.id"
      :num="item.click"
      :price="item.add_time"
      :title="item.title"
      :thumb="item.img_url"
      @click="goDetail(item.id)"
    >
      <template #price>
        <div>{{ item.add_time }}</div>
      </template>
      <template slot="num">
        <div>阅读{{ item.click }}</div>
      </template>
    </van-card>
  </div>
</template>
<script>
import { getNewsList } from '@/api/news'

export default {
  data: () => ({
    newslist: []
  }),
  created() {
    this.getNewsList()
  },
  methods: {
    async getNewsList() {
      const res = await getNewsList()
      this.newslist = res.data.message
    },
    goDetail(id) {
      this.$router.push('/home/newsinfo/' + id)
    }

  }
}
</script>

<style lang="less" scoped>
.news-list {
  .van-card__content {
    min-height: 55px;
  }
  .van-card__thumb {
    height: 55px;
  }
  .van-card__price {
    color: red;
  }
  .van-card__title {
    -webkit-line-clamp: 1;
    /* 将对象作为弹性伸缩盒子模型显示 */
    display: -webkit-box;
    /*子元素的排列方式 */
    -webkit-box-orient: vertical;
    text-overflow: ellipsis;
    overflow: hidden;
    word-break: break-all;
  }
}
</style>